
Imports BUS
Imports DTO
Public Class QuyDinh
    Dim maqd As Integer
    Dim tenquydinh As String
    Dim gt As Integer
    Private Sub QuyDinh_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Dim bangQD As New DataTable
            Dim qdBUS As New QuyDinhBUS

            bangQD = qdBUS.LayBang()
            gridQD.Columns(0).DataPropertyName = bangQD.Columns(0).ColumnName
            gridQD.Columns(1).DataPropertyName = bangQD.Columns(1).ColumnName
            gridQD.Columns(2).DataPropertyName = bangQD.Columns(2).ColumnName

            gridQD.DataSource = bangQD
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub butCapNhat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butCapNhat.Click
        Try
            Dim qd As New QuiDinhDTO
            qd.TenQuyDinh = txtTenQuyDinh.Text
            qd.MaQuyDinh = maqd
            qd.GiaTri = txtGiaTriQuyDinh.Text
            Dim qdBUS As New QuyDinhBUS
            qdBUS.CapNhatQuyDinh(qd)
            gridQD.DataSource = qdBUS.LayBang()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub gridQD_CellMouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles gridQD.CellMouseClick
        Try
            txtTenQuyDinh.Text = gridQD.CurrentRow.Cells(1).Value
            txtGiaTriQuyDinh.Text = gridQD.CurrentRow.Cells(2).Value
            maqd = gridQD.CurrentRow.Cells(0).Value
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
End Class
